package com.example.mybatisexercise1.indent;

import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface InddentMapper {
//    添加一个订单：insert
@Insert("INSERT INTO orders VALUES (NULL,#{state},#{amount},#{created})")
    void insert(Indent indent);
//    查询所有订单：selectAll
@Select("SELECT * FROM orders ")
List<Indent> selectAll();
//    通过id查询1个订单：selectOne
@Select("SELECT * FROM orders WHERE id=#{id} ")
List<Indent>  selectOne(Indent indent);
//    通过id修改1个订单：upadteOne
@Update("UPDATE orders SET state=#{state},created=#{created},amount=#{amount} WHERE id=#{id}")
void updateOne(Indent indent);
//    通过一个id删除订单：deleteById
    @Delete("DELETE FROM orders WHERE id=#{id}")
    void deleteById(Indent indent);

//    统计订单总数：selectCount
    @Select("SELECT COUNT(*) FROM orders")
    int selectCount(Indent indent);

//    查询所有订单的订单状态statas和订单金额amount：封装到 OrderVO
    @Select("SELECT state,amount FROM orders")
    List<OrderVO> selectTwo(OrderVO orderVO);
}
